package com.aliyun.frontframework;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 这里参数是可以动态变化的。每次录制完了需要检查
 * 
 * @author allan
 * 
 */
public class DVRRecordParamModel implements Parcelable {
	public int _p; // 720p 1204p
	public int duration; // 1min 3min 5min
	public byte isSound; // 是否录音
	public int width; // 这里应该是固定的
	public int height;// 这里应该是固定的
	public int cameraId;
	public int sensor;
	public int gravity;

	public DVRRecordParamModel() {
	}

	@Override
	public String toString() {
		return "_p " + _p + " duration " + duration + " isSound " + isSound + " w "
				+ width + " h " + height + " cameraId " + cameraId + " sensor "
				+ sensor + " grav " + gravity;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(_p);
		dest.writeInt(duration);
		dest.writeByte(isSound);
		dest.writeInt(width);
		dest.writeInt(height);
		dest.writeInt(cameraId);
		dest.writeInt(sensor);
		dest.writeInt(gravity);
	}

	public static final Parcelable.Creator<DVRRecordParamModel> CREATOR = new Parcelable.Creator<DVRRecordParamModel>() {
		@Override
		public DVRRecordParamModel createFromParcel(Parcel in) {
			return new DVRRecordParamModel(in);
		}

		@Override
		public DVRRecordParamModel[] newArray(int size) {
			return new DVRRecordParamModel[size];
		}
	};

	public static boolean isNeedRestartService(DVRRecordParamModel param1,
			DVRRecordParamModel param2) {
		if (param1.cameraId != param2.cameraId) {
			return true;
		}
		if (param1._p != param2._p) {
			return true;
		}
		if (param1.isSound != param2.isSound) {
			return true;
		}
		if (param1.width != param2.width) {
			return true;
		}

		if (param1.height != param2.height) {
			return true;
		}

		return false;
	}

	private DVRRecordParamModel(Parcel in) {
		_p = in.readInt();
		duration = in.readInt();
		isSound = in.readByte();
		width = in.readInt();
		height = in.readInt();
		cameraId = in.readInt();
		sensor = in.readInt();
		gravity = in.readInt();
	}
}
